package cn.exrick.xboot.modules.masterdata.server.call;

import cn.exrick.xboot.modules.masterdata.entity.dto.MasterUserDto;
import cn.exrick.xboot.modules.masterdata.server.getData.IMdmSubscribe;
import cn.exrick.xboot.modules.masterdata.server.getData.MdmSubscribeServiceLocator;
import cn.exrick.xboot.modules.masterdata.server.utils.Dom4JforXML;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class CallMasterGetData {
    @Value("${masterdata.pageSize}")
    private   String pageSize;

    public String getData() {
        String data=null;
        try {
            MdmSubscribeServiceLocator locator = new MdmSubscribeServiceLocator();
            IMdmSubscribe mdmSubscribeServicePort = locator.getMdmSubscribeServicePort();
            data = mdmSubscribeServicePort.getData("PORTAL", getDataXML());
            MasterUserDto masterUserDto = Dom4JforXML.xmlToMasterUserDto(data);
            log.info("主数据增量：masterUserDto{}",masterUserDto);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return data;
    }

    public  String getDataXML( ){
        if("".equals(pageSize)){
            pageSize="100";
        }
        System.out.println("pageSize:"+pageSize);
        String soapXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                +"  <query>"
                +"  <pageSize>"+pageSize+"</pageSize>"
                +"  <currentPage>1</currentPage>"
                +"  <totalRecord>0</totalRecord>"
                +"  </query> ";
        System.out.println("请求报文："+soapXML);
        return soapXML;
    }
    class page{
        private  Integer pageSize;
        private Integer currentPage;
    }


}
